package com.simple.mipclient.server.func;

import android.content.Context;
import android.widget.Toast;

import com.simple.mipc.annotation.OnApply;
import com.simple.mipc.annotation.Param;
import com.simple.mipc.annotation.Res;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import lombok.extern.slf4j.Slf4j;

/**
 * 对外暴露的接口
 */
@Slf4j
public class TestFunction {

    private Context context;

    private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public TestFunction(Context context) {
        this.context = context;
    }

    @OnApply
    @Res("/server/test")
    public String test(@Param("msg") String msg) {
        log.info(msg);
        String format = String.format("ipc服务端测试，时间：%s", LocalDateTime.now().format(DATE_TIME_FORMATTER));
        Toast.makeText(context, format, Toast.LENGTH_LONG).show();
        return format;
    }
}
